<template id="coupon">
	<div class="coupon">
		<!--头部-->
		<div class="about_header">

			<div class="about_title">
				<span @click.stop="reset"><img src="../../assets/images/class/jiantou_03.png" /></span>

				<p>优惠券</p>
				<div class="about_select">
					<div class="about_ing"></div>
				</div>

			</div>
		</div>
		<!--头部结束-->

		<!--头部导航-->
		<div class="coupon_nav">
			<ul>
				<li><router-link :to="{path: '/coupon_workability', query: {status: $route.query.status}}">可使用({{sumber}})</router-link></li>
				<li><router-link :to="{path: '/coupon_already', query: {status: $route.query.status}}">已使用</router-link></li>
				<li><router-link :to="{path: '/coupon_overdue', query: {status: $route.query.status}}">已过期</router-link></li>

			</ul>
			<router-view></router-view>


		</div>

		<!--头部导航结束-->



	</div>
</template>

<script>
	export default {
		data() {
            return{
			   sumber:''
               
            }
       },
	  created() {
      coupon:{
      		//let SESSION_ID = JSON.parse(window.sessionStorage.getItem('SESSION_ID'));
			   var SESSION_ID=JSON.parse(window.localStorage.getItem('sessiond'))
    	let obj = {
				//请求的参数
				userid:SESSION_ID.user.id ,
			};
			var _this = this
			let qs = require('qs');
			this.$axios.post("http://yogahome.top/yujia/user/findValidCouponByUser", qs.stringify(obj), {
				headers: {
					'Content-Type': 'application/x-www-form-urlencoded'
				}
				//重写headers 请求头  qs.stringify(json对象) 把对象转化为字符串 
			}).then(function(response) {
				console.log(response.data.data)
				_this.coupon = response.data.data
				_this.sumber = _this.coupon.length;
			}).catch(function(error) {
				console.log(error);
			});
    }
    },
		methods: {
			reset() {
        let {status} = this.$route.query;
        if(status === '1'){
					this.$router.push({
						path: '/my_order'
					})
				}else if(status === '2') {
					this.$router.push({
						path: '/main'
					})
				}

			}
		}
	}
</script>

<style scoped>
	@import "../../assets/css/coupon.css";
</style>
